package home.projects.recipes.chapthree;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("service")
public class SequenceGeneratorService {
   
   @Autowired
   private ISequenceDAO sequenceDao;

   public void setSequenceDao(ISequenceDAO sequenceDao) {
      this.sequenceDao = sequenceDao;
   }   
   
   public String getSequence(String sequenceId) {
      Sequence sequence = sequenceDao.getSequence(sequenceId);
      int i = sequenceDao.getNextValue(sequenceId);
      return sequence.getPrefix() + i + sequence.getSuffix();      
   }
   
}
